home *** CD-ROM | disk | FTP | other *** search
- %!
- %%VMusage: 0 0
- %%VMlocation: global
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- %% %%
- %% OPIProcSet: procedures to go into CommentDict to enable basic %%
- %% OPI processing, for OPI version 2.0. This procset should be able %%
- %% to handle both version 1 and version 2 comments as well as files %%
- %% that include both. %%
- %% %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
- /OPI2.0ProcSet <<
-
- /Initialise {
- userdict /OPIinitialised? known {
- userdict /OPIinitialised? get
- } {
- false
- } ifelse
- not {
- currentglobal false setglobal
- userdict /OPIdocomment {
- dup length string cvs
- 3 -1 roll exch anchorsearch pop pop
- (: ) anchorsearch pop pop
- OPIdict 3 1 roll put
- } put
- userdict /OPIdoobject_v1 {
- /OPI2.0ProcSet /ProcSet findresource begin DoObject_v1 end
- } put
- userdict /OPIdoobject_v2 {
- /OPI2.0ProcSet /ProcSet findresource begin DoObject_v2 end
- } put
- userdict /OPIdict 12 dict put
- userdict /OPIinitialised? true put
- setglobal
- } if
- } bind
-
- /Known {
- 2 copy known {
- 1 index exch get true
- } {
- pop false
- } ifelse
- } bind
-
- %%
- %% OPIdict filename => OPIdict paramsdict file true
- %% See the manual before adding file types to this procedure.
- %%
- /FindFile {
- mark {
- 8 dict
- 2 index dup 0 get 16#28 eq {cvx exec} if
- (r) file 1 index /TIFFDecode filter
- } stopped {
- cleartomark false
- } {
- 4 2 roll pop pop true
- } ifelse
- } bind
-
- %%
- %% OPIdict paramsdict file => -
- %%
- %% The code below does not always manage to do the right thing if the
- %% Distilled keyword is present. This is largely because not enough
- %% information is recorded in a PDF OPI dictionary. In this case we
- %% execute stop to cause the low res image to be used instead.
- %%
- /DoImage {
- exch begin
- 8 dict begin
- /ImageType 1 def
- /Width Width def
- /Height Height def
- /DataSource exch def
- /BitsPerComponent BitsPerComponent def
- /ImageMask false def
-
- gsave
- /ALDImagePosition Known {
- cvx exec
- 6 index sub exch 7 index sub exch
- 6 -2 roll
- 6 index sub exch 7 index sub exch
- 6 -2 roll pop pop
- 6 -2 roll matrix astore concat
- 0 0 1 1 rectclip
- } if
-
- dup /ALDImageDimensions known
- 1 index /ALDImageCropRect known and {
- dup /ALDImageDimensions get cvx exec
- 2 index /ALDImageCropRect get cvx exec
- 3 -1 roll sub 3 index exch div
- 3 1 roll exch sub 3 index exch div
- exch scale
- 2 index /ALDImageCropRect get cvx exec
- 4 1 roll pop pop 3 index div neg
- exch 2 index sub 2 index div
- translate
- pop pop
- } if
-
- /ALDImageOverprint Known {cvx exec setoverprint} if
-
- /ImageMatrix [Width 0 0 Height neg 0 Height] def
-
- Photometric 2 lt 1 index /Version get 2 eq and 1 index /Distilled known not and {
- /ImageInks Known {
- token {
- exch pop /monochrome eq
- } {
- false
- } ifelse
- } {
- false
- } ifelse
- } {
- false
- } ifelse
- {
- Width Height BitsPerComponent ImageMatrix DataSource
- end end
- OPIimage
- } {
- Photometric 2 lt {
- /ALDImageTint Known {cvx exec} {1} ifelse /ImageTint exch def
- /ALDImageGrayMap Known {
- [ [ 3 -1 roll cvx exec ] /exch load 1 index length
- Photometric 0 eq {1 /exch load /sub load 4 -1 roll} if
- 1 sub /mul load /cvi load /get load 65535 /div load] cvx settransfer
- } if
- /Decode [0 ImageTint Photometric 0 eq {exch} if ] def
- BitsPerComponent 1 eq {
- /ALDImageTransparency Known {cvx exec} {true} ifelse
- /ImageMask exch def
- } if
- /ImageInks Known {
- token pop
- (monochrome) eq {
- token pop
- dup 1 eq {
- cvx exec
- /ImageTint exch def
- false currentpagedevice /SeparationOrder get {
- 1 index eq {pop true exit} if
- } forall
- not {stop} if
- [/Separation 3 -1 roll /DeviceGray {}] setcolorspace
- } {
- 4 eq {
- cvx exec
- 4 dict begin 4 {def} repeat
- currentdict end
- dup /Cyan known 1 index /Magenta known and
- 1 index /Yellow known and 1 index /Black known and
- not {stop} if
- begin
- [/Indexed /DeviceCMYK 255 [ 255 /div Cyan Magena Yellow Black end
- systemdict /stdtinttransform get] cvx ] setcolorspace
- ImageMask {
- 255 ImageTint mul round cvi setcolor
- } {
- /Decode [0 255 ImageTint mul round cvi Photometric 0 ne {exch} if] def
- } ifelse
- } {
- mark exch cvx exec counttomark 2 idiv dup dict begin {
- dup 0 eq {pop pop} {
- exch (Hexachrome ) anchorsearch {pop} if exch def
- } ifelse
- } repeat
- currentdict
- true 1 index {
- false currentpagedevice /SeparationOrder get {
- 1 index eq {pop true exit} if
- } forall
- not {stop} if
- } forall
- [/Indexed [/DeviceN [currentdict {pop} forall]
- /DeviceGray [currentdict length {pop} /repeat load 1] cvx bind]
- [255 /div load currentdict {
- exch pop /dup load exch /mul load /exch load} forall /pop load
- ] cvx bind] setcolorspace
- end
- /Decode [0 255 ImageTint mul round cvi Photometric 0 ne {exch} if] def
- } ifelse
- } ifelse
- } {
- pop [/Separation /All /DeviceCMYK {dup dup dup}] setcolorspace
- } ifelse
- } {
- /ALDImageColor Known {cvx exec} {0 0 0 1 (Black)} ifelse
- 6 -1 roll /ALDImageColorType Known not {(Spot)} if exch 7 1 roll
- dup (Separation) eq {
- pop pop [/Separation /All /DeviceCMYK {dup dup dup}] setcolorspace
- } {
- (Process) eq {
- pop
- [/Indexed /DeviceCMYK 255 [ 255 /div load 11 -4 roll
- systemdict /stdtinttransform get] cvx ] setcolorspace
- ImageMask {
- 255 ImageTint mul round cvi setcolor
- } {
- /Decode [0 255 ImageTint mul round cvi Photometric 0 ne {exch} if] def
- } ifelse
- } {
- [/Separation 3 -1 roll /DeviceCMYK [ 9 -4 roll
- systemdict /stdtinttransform get] cvx ] setcolorspace
- } ifelse
- } ifelse
- } ifelse
- } if
- Photometric 2 eq {
- /DeviceRGB setcolorspace
- /Decode [0 1 0 1 0 1] def
- } if
- Photometric 3 eq {
- [/Indexed /DeviceRGB Palette length 3 idiv 1 sub Palette] setcolorspace
- /Decode [0 Palette length 3 idiv 1 sub] def
- } if
- Photometric 5 eq {
- /DeviceCMYK setcolorspace
- /Decode [0 1 0 1 0 1 0 1] def
- } if
- /ALDImageOperation Known {
- cvx exec
- } {
- currentdict ImageMask end end
- {imagemask} {image} ifelse
- } ifelse
- } ifelse
- pop
- grestore
- } bind
-
-
- /CommentDict <<
- /ALDImageFileName {/ALDImageFileName dup OPIdocomment}
- /ALDImageID {/ALDImageID dup OPIdocomment}
- /ALDImageDimensions {/ALDImageDimensions dup OPIdocomment}
- /ALDImageCropRect {/ALDImageCropRect dup OPIdocomment}
- /ALDImagePosition {/ALDImagePosition dup OPIdocomment}
- /ALDImageColor {/ALDImageColor dup OPIdocomment}
- /ALDImageColorType {/ALDImageColorType dup OPIdocomment}
- /ALDImageTint {/ALDImageTint dup OPIdocomment}
- /ALDImageOverprint {/ALDImageOverprint dup OPIdocomment}
- /ALDImageTransparency {/ALDImageTransparency dup OPIdocomment}
- /ALDImageGrayMap {/ALDImageGrayMap dup OPIdocomment}
- /BeginObject {pop OPIdoobject_v1}
- /ImageFileName {/ALDImageFileName /ImageFileName OPIdocomment}
- /MainImage {/ALDImageID /MainImage OPIdocomment}
- /ImageDimensions {/ALDImageDimensions /ImageDimensions OPIdocomment}
- /ImageCropRect {/ALDImageCropRect /ImageCropRect OPIdocomment}
- /ImageOverprint {/ALDImageOverprint /ImageOverprint OPIdocomment}
- /ImageInks {/ImageInks dup OPIdocomment}
- /Distilled {pop OPIdict /Distilled true put}
- /BeginIncludedImage {pop OPIdoobject_v2}
- >>
-
- /DoObject_v1 {
- 2 dict begin
- /opi_junk 2048 string def
- userdict /OPIdict get dup /ALDImageFileName known
- exch /ALDImageID known or {
- currentfile opi_junk {readline} stopped {
- pop
- } {
- pop
- /opi_nextline exch def
- opi_nextline (%%BeginOPI: 2.0) eq {
- userdict /OPIdict get dup {pop 1 index exch undef} forall
- } {
- userdict /OPIdict get
- dup /Version 1.3 put
- /ALDImageID Known not {
- /ALDImageFileName Known pop
- } if
- dup type /dicttype ne {
- mark 3 1 roll
- FindFile {
- {DoImage} stopped
- } {
- true
- } ifelse
- {
- (%%[ OPI substitution failed; using low resolution image ]%%) = flush
- pop
- opi_nextline length 0 gt {opi_nextline 0 get 16#25 ne} {false} ifelse {
- % opi_nextline 0 get 16#25 ne {
- opi_nextline end cvx exec
- 1 dict begin
- } if
- } {
- opi_nextline (%%EndObject) ne {
- {
- currentfile opi_junk {readline} stopped {
- pop pop
- } {
- not {stop} if
- (%%EndObject) eq {exit} if
- } ifelse
- } loop
- } if
- } ifelse
- cleartomark
- } {
- pop
- } ifelse
- } ifelse
- } ifelse
- } if
- end
- } bind
-
- /DoObject_v2 {
- userdict /OPIdict get
- dup /Version 2 put
- /ALDImageID Known not {
- /ALDImageFileName Known pop
- }{
- exch pop
- } ifelse
- dup type /dicttype ne {
- mark 3 1 roll
- FindFile {
- {DoImage} stopped
- } {
- true
- } ifelse
- {
- (%%[ OPI substitution failed; using low resolution image ]%%) = flush
- } {
- 1 dict begin
- /opi_junk 2048 string def
- {
- currentfile opi_junk {readline} stopped {
- pop pop
- } {
- not {stop} if
- (%%EndOPI) eq {exit} if
- } ifelse
- } loop
- end
- } ifelse
- cleartomark
- } {
- pop
- } ifelse
- userdict /OPIdict 12 dict put
- } bind
-
- >> /ProcSet defineresource
-
- dup /Initialise get exec
-
-